package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author chenjijiang
 * @description
 */
@Data
@Entity
@Table(name = "PRD_INFO")
@DynamicUpdate
@DynamicInsert
@Accessors(chain = true)
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PrdInfo implements Serializable {
	private static final long serialVersionUID = -5240146117478843283L;
	//新定价
	public static final Integer prdInfoSystemFlag_1=1;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PRODUCCT_INFO_SEQ")
	@SequenceGenerator(name = "PRODUCCT_INFO_SEQ", allocationSize = 1, sequenceName = "PRODUCCT_INFO_SEQ")
	@Column(name = "PRDINFOID")
	private Long prdInfoId; // 商品包ID
	@Column(name = "PARENT_ID")
	private Long parent; // 父栏目ID
	@Column(name = "NAME")
	private String name; // 产品包名称
	@Column(name = "DESCRIPTION")
	private String description; // 产品包描述
	@Column(name = "TYPE")
	private Integer type; // 产品类型 1：和视界 2：和视频 3.内容输出
	@Column(name = "BC_ID")
	private Long bcId; // 播控方
	@Column(name = "SP_ID")
	private Long spId; // spId;
	@Column(name = "IS_PUBLISH")
	private Integer isPublish; // 是否发布  1：未发布 2：已发布 3：已撤回
	@Column(name = "PRD_INFO_TYPE")
	private Integer prdInfoType; // 产品包类型：1：垂直栏目 2:品牌栏目 3：V+
	@Column(name = "CREATE_TIME")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime createTime; // 创建时间
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "UPDATE_TIME")
	private LocalDateTime updateTime; // 更改时间
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "PUB_TIME")
	private LocalDateTime pubTime; // 发布时间
	@Column(name = "IS_BC")
	private Integer isBc; // 是否全部播控

	@Column(name = "MONTH_TYPE")
	private String monthType; // 包月类型

	@Column(name = "NUMBER_TYPE")
	private String numberType; // 按此类型

	@Column(name = "FREE_TYPE")
	private String freeType; // 免费类型

	@Column(name = "PRIORITY")
	private Integer priority; // 产品包优先级

	@Column(name = "PRODUCT_ID")
	private Long productId; // 产品编号

	@Column(name = "SAL_CATEGORY")
	private Integer salCategory; // 促销类型 1.预售 2.预订 3.限免

	@Column(name = "START_TIME")
	private String startTime; // 开始时间

	@Column(name = "END_TIME")
	private String endTime; // 结束时间

	@Column(name = "SUPPORT_ID")
	private Long supportId; // 支撑方ID

	@Column(name = "MONTH_PRICE")
	private String monthPrice; //包月价格

	@Column(name = "NUMBER_PRICE")
	private String numberPrice; //按次价格

	@Column(name = "IS_OUTPUT")
	private Integer isOutput; //是否输出内容;0:否;1:是

	@Column(name = "AUTO_VOMS_PUBLISH")
	private Integer autoVomsPublish; //是否自动发布内容;0:否;1:是

	@Column(name = "IS_PUBRULE_ON")
	private Integer isPubRuleOn; //是否启用自动发布规则  0：否 , 1：是

	@Column(name = "PARENT_PRDINFO_ID")
	private Long parentPrdInfo; //父产品包

	@Column(name = "RECOMMEND_BC")
	private String recommendBc;    //推荐标签播控

	@Column(name = "ALIAS")
	private String alias;    //别名, 多个别名之间逗号分隔

	@Column(name = "CREATOR")
	private String creator;    //创建人

	@Column(name = "DELEGATOR")
	private String delegator;    //委托人

	@Column(name = "UN_SUPPORT_ID")
	private Long unSupportId; //最次优先级

	@Column(name = "EQUITY_ID")
	private String equityId;//权益

	@Column(name = "PRODUCT_INFO_PACKAGE_ID")
	private Long productInfoPackageId;//产品包对应的产品id  对应二级产品     当一级产品存在，而二级产品不存在是  productInfoPackageId = 0

	//private Long productInfoPackageType;//产品包对应的类型   -->业务类型  对应一级产品
	@Column(name = "FIRST_PRODUCT_INFO_PACKAGE_ID")
	private Long firstProductInfoPackageId;//产品包对应的类型   -->业务类型  对应一级产品

	@Column(name = "ENTER_PRDINFO_PRIORITY")
	private Integer enterPrdInfoPriority;//入包优先级

	@Column(name = "SYSTEM_FLAG")
	private Integer systemFlag;//区分poms和新批价系统，新批价为1，其余为poms

	public static void putTimeAndUser(PrdInfo prdInfo) {
		if (prdInfo.prdInfoId == null) {
			prdInfo.setCreateTime(java.time.LocalDateTime.now());
		}
		prdInfo.setUpdateTime(java.time.LocalDateTime.now());
	}
}
